<template>
  <Table
    :columns="columns"
    :page-function="page"
    :save-all-function="saveAll"
  >
  </Table>

</template>

<script>
import {saveAll, page} from '@/api/word'
import Table from '@/components/Table'
import {commonList} from "@/utils/common";
import {list as listWordType} from "@/api/wordType";
import {list as listWordClass} from "@/api/wordClass";

export default {
  name: 'Word',
  components: {Table},
  data() {
    return {
      saveAll: saveAll,
      page: page,
      row: {},
      wordTypes: [],
      wordClasses: [],
    }
  },
  computed: {
    columns() {
      return [
        {
          prop: 'id',
          label: '序号',
          width: '80',
          form: {
            key: 'id',
            label: 'id',
          },
        },
        {
          prop: 'name',
          label: '名称',
          width: '180',
          form: {
            key: 'name',
            label: '名称',
            type: 'input',

          }
        },
        {
          prop: 'wordType.name',
          label: '类型',
          width: '180',
          form: {
            key: 'typeId',
            label: '类型',
            type: 'select',
            options: this.wordTypes
          }
        },
        {
          prop: 'wordClass.name',
          label: '词性',
          width: '180',
          form: {
            key: 'classId',
            label: '词性',
            type: 'select',
            options: this.wordClasses
          }
        },
        {
          prop: 'createTime',
          label: '创建时间',
          width: '200px'
        },
        {
          prop: 'updateTime',
          label: '更新时间',
          width: '200px'
        },
        {
          label: '操作',
          type: 'action',
          buttons: []
        }
      ]
    }
  },
  beforeMount() {
    this.listWordType()
    this.listWordClass()
  },
  methods: {
    listWordType() {
      commonList(this.wordTypes, listWordType, false)
    },
    listWordClass() {
      commonList(this.wordClasses, listWordClass, false)
    }
  }

}
</script>

<style scoped>

</style>
